// 引入外部资料库
import { login } from "../../utils/asyncWx";
import { request } from "../../request/index";
import regeneratorRuntime from "../../libs/runtime";

Page({
  async handleGetUserInfo(e) {
    // 获取用户信息
    const { encryptedData, rawData, signature, iv } = e.detail;
    // 获取小程序登录成功后的 code
    const { code } = await login();
    const loginParams = { encryptedData, rawData, signature, iv, code };
    // 发送请求获取用户的 token
    // ERROR(没有企业微信无法获取到 token 值)
    const res = await request({
      url: "/users/wxlogin",
      data: loginParams,
      methods: "post",
    });
    console.log(res);
  },
});
